package com.zbkj.admin.controller.publicly;

import cn.hutool.core.date.DatePattern;
import com.zbkj.admin.service.JobService;
import com.zbkj.dal.base.result.CommonResult;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDateTime;

@RestController
public class JobController {

    @Autowired
    private JobService jobService;

    @GetMapping("/job/rent-wait-return")
    @ApiModelProperty("定时任务，承享待归还检测，将到期的承享订单标记为待归还， 1天可以执行多次")
    public CommonResult<?> rentWaitReturn(@RequestParam(required = false)
                                          @DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN)
                                          LocalDateTime time) {
        jobService.rentWaitReturn(time);
        return CommonResult.success();
    }

    @GetMapping("/job/rent-return-overdue-deduction-auto")
    @ApiModelProperty("定时任务，承享超期自动抵扣定是任务")
    public CommonResult<?> rentReturnOverdueDeductionAuto() {
        jobService.rentReturnOverdueDeductionAuto();
        return CommonResult.success();
    }

    @GetMapping("/job/rent-return-overdue-close")
    @ApiModelProperty("定时任务，承享超期自动抵扣定是任务")
    public CommonResult<?> rentReturnOverdueClose() {
        jobService.rentReturnOverdueClose();
        return CommonResult.success();
    }

}
